package com.oba.king.datalib.paymenttype;

import java.util.Date;

import com.oba.base.dao.DBDataModel;
import com.oba.base.service.BaseBean;
import com.oba.king.datalib.deliverytype.DeliveryType;

/**
 * 
 * @author 大饼
 * 付款方式管理
 */
public class PaymentTypeBean extends BaseBean<PaymentType, PaymentTypeService>{
	private DBDataModel paymentTypeData = DBDataModel.create();
    private PaymentType paymentType;
    
    private String paymentTypeName;
    
    private boolean showpaymentType;
    
    public String doFind(){
  	  paymentTypeData.find(getService().getDao().findAll());
  	  return null;
  	  
    }
    
    public void findByPaymentName(){
  	  paymentTypeData.find(getService().getDao().findByPaymentName(paymentTypeName));
    }
    
    public void clearPaymentType(){
  	  paymentTypeName=null;
    }
    

	public void doAddRow(){
		paymentType=new PaymentType();
		paymentType.setNewBo(true);
		paymentType.setCreateDate(new Date());
		paymentType.setInActive("Y");
		showpaymentType=true;
	}
	
	public void doDeleteRow() {
		if(paymentTypeData.isRowAvailable()) {
			paymentType = (PaymentType) paymentTypeData.getRowData();
			getService().del(paymentType);
			doFind();
		}
	}
	
	public void doEditRow() {
		if(paymentTypeData.isRowAvailable()) {
			paymentType = (PaymentType) paymentTypeData.getRowData();
			paymentType.setUpdateDate(new Date());
			showpaymentType = true;
			doFind();
		}
	}
	
	public void closeShowEdit() {
		showpaymentType = false;
	}
	
	public void doSaveRow() {

		getService().save(paymentType);
		showpaymentType = false;
		doFind();
	}
	

	@Override
	public void init() {
		paymentTypeData.find(getService().getDao().findAll());
		paymentType =new PaymentType();
		showpaymentType = false;
	}
	

	public DBDataModel getpaymentTypeData() {
		return paymentTypeData;
	}


	public void setpaymentTypeData(DBDataModel paymentTypeData) {
		this.paymentTypeData = paymentTypeData;
	}


	public PaymentType getPaymentType() {
		return paymentType;
	}


	public void setPaymentType(PaymentType paymentType) {
		this.paymentType = paymentType;
	}


	public String getPaymentTypeName() {
		return paymentTypeName;
	}


	public void setPaymentTypeName(String paymentTypeName) {
		this.paymentTypeName = paymentTypeName;
	}


	public boolean isShowpaymentType() {
		return showpaymentType;
	}


	public void setShowpaymentType(boolean showpaymentType) {
		this.showpaymentType = showpaymentType;
	}


}
